﻿namespace BotDetector.Core.TextPreprocessing
{
    public class TextPreprocessor
    {
        public string Preprocess(string text)
        {
            text = StopWordRemover.CleanSearchedWords(text);
            if(text != "")
            {
                text = text.Remove(text.Length - 1);
            }

            string[] words = text.Split(' ');
            PorterStemmer stemmer = new PorterStemmer();

            text = "";
            foreach (string word in words)
            {
                stemmer.add(word.ToCharArray(), word.Length);
                stemmer.stem();
                string x = stemmer.ToString();
                text += x + " ";
            }

            text = text.Remove(text.Length - 1);
            return text;
        }
    }
}
